package cn.lystudio.rohmtimeopwide_background_v11.dtree;

import cn.lystudio.rohmtimeopwide_background_v11.enums.ApiStatus;
import cn.lystudio.rohmtimeopwide_background_v11.exceptions.BaseException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class DTreeResponse {
    /** 状态类*/
    private DTreeStatus status;
    /** 数据*/
    private Object data;

    private static DTreeResponse of(DTreeStatus status,Object data){
        return new DTreeResponse(status,data);
    }

    public static DTreeResponse ofSuccessData(Object data){
        return of(new DTreeStatus(ApiStatus.OK.getCode(), ApiStatus.OK.getMessage()),data);
    }

    public static <T extends BaseException> DTreeResponse ofException(T t){
        return of(new DTreeStatus(ApiStatus.UNKNOWN_ERROR.getCode(),ApiStatus.UNKNOWN_ERROR.getMessage()),null);
    }
}
